package com.neusoft.mapper;

import com.neusoft.core.VirtualWallet;
import org.apache.ibatis.annotations.*;

import java.math.BigDecimal;

@Mapper
public interface VirtualWalletMapper {

    @Select("select * from virtualWallet where walletId=#{walletId}")
    VirtualWallet getVirtualWalletById(Integer walletId);

    @Update("update virtualWallet set balance = #{balance} where walletId = #{walletId}")
    int updateBalance(@Param("walletId") Integer walletId, @Param("balance") BigDecimal balance);

    @Insert("INSERT INTO virtualWallet(userId, createTime, balance, isAllowedOverdraft, overdraftAmount, frozenAmount) " +
            "VALUES(#{userId}, #{createTime}, #{balance}, #{isAllowedOverdraft}, #{overdraftAmount}, #{frozenAmount})")
    @Options(useGeneratedKeys = true, keyProperty = "walletId", keyColumn = "walletId")
    int saveVirtualWallet(VirtualWallet virtualWallet);
}
